Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR ensures the Downloads “supernav” and related download boxes refresh immediately when a ReleaseFile is added/changed/deleted, avoiding the need to “double save” a Release to see updates.
Changes:
- Add
post_saveandpost_deletesignal handlers forReleaseFileto trigger supernav + box regeneration. - Purge the Fastly
/box/*endpoints whenReleaseFilechanges on a published Release. - Add model tests asserting box update functions are (or aren’t) triggered based on Release publish status.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/downloads/models.py | Adds ReleaseFile save/delete signal handlers to refresh boxes and purge cached box URLs. |
| apps/downloads/tests/test_models.py | Adds tests verifying the new signal-driven updates run only for published releases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| purge_url("/box/supernav-python-downloads/") | ||
| purge_url("/box/homepage-downloads/") | ||
| purge_url("/box/download-sources/") |
There was a problem hiding this comment.
The list of box purge URLs is duplicated here and in purge_fastly_download_pages() above. To avoid future drift (e.g., adding/removing a box in one place but not the other), consider centralizing these paths in a shared constant or a small helper used by both code paths.
|
|
||
| def _update_boxes_for_release_file(instance): | ||
| """Update supernav and download boxes if the file's release is published.""" | ||
| if instance.release_id and instance.release.is_published: |
There was a problem hiding this comment.
_update_boxes_for_release_file() dereferences instance.release to check is_published, which can introduce an extra DB query on each ReleaseFile save/delete when the Release isn’t already cached. If this handler ends up being called frequently, consider checking publication status via a lightweight query (e.g., Release.objects.filter(pk=instance.release_id, is_published=True).exists()) to avoid loading the full Release object.
| if instance.release_id and instance.release.is_published: | |
| if instance.release_id and Release.objects.filter(pk=instance.release_id, is_published=True).exists(): |
Description